package com.jw.system.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jw.response.Result;
import com.jw.system.entity.Customer;
import com.jw.system.entity.vo.UserVO;
import com.jw.system.service.CustomerService;
import com.jw.system.service.RoleService;
import com.jw.system.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 客户表 前端控制器
 * </p>
 *
 * @author jw
 * @since 2021-04-20
 */
@RestController
@RequestMapping("/cus")
@Api(value = "系统客户模块", tags = "系统客户接口")
public class CustomerController {

    @Autowired
    private CustomerService customerService;


    /**
     * 获取用户列表
     * @return
     */
    @ApiOperation(value = "客户列表", notes = "模糊查询客户列表")
    @PostMapping("/getCusList")
    public Result getCusList(@RequestParam(value = "current", defaultValue = "1") Integer current,
                              @RequestParam(value = "size", defaultValue = "7") Integer size,
                              @RequestBody Customer customer){
        Page<Customer> cusList = customerService.getCusList(current, size, customer);
        return Result.ok().data("cusList",cusList.getRecords()).data("total",cusList.getTotal());
    }

    /**
     * 获取用户列表
     * @return
     */
    @ApiOperation(value = "客户列表", notes = "获取客户列表")
    @GetMapping("/findAll")
    public Result getAllCus(){
        List<Customer> cusList = customerService.getAllCus();
        return Result.ok().data("cusList",cusList);
    }

}

